package com.yunshang.shoppingmall.common;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class IOFile {

    public static boolean SetText(String path, String data,boolean append) {
        File file = new File(path);
        try {
            //if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }

            //true = append file
            FileWriter fileWritter = new FileWriter(file.getName(), append);
            fileWritter.write(data);
            fileWritter.close();

            return true;

        } catch (IOException e) {
            return true;
        }
    }

    public static boolean SetText(String path, String data) {
        return SetText(path,data,false);
    }

    public static boolean SetTextT(String path, String data) {
        return SetText(path,data,true);
    }

}